var app = getApp();

Page({
  data: {

  },

  onReady: function() {
  },

  moveToMyInformation: function(event) {
    wx.navigateTo({
      url: '/pages/myInformation/myInformation'
    });
  },

  moveToHistoryOperation: function(event) {
    wx.navigateTo({
      url: '/pages/historyOperation/historyOperation'
    });
  },

  moveToMySocialContact: function(event){
    wx.navigateTo({
      url: '/pages/mySocialContact/mySocialContact'
    });
  },

  moveToQuestionnaire: function (event) {
    wx.navigateTo({
      url: '/pages/questionnaire/questionnaire'
    });
  },

  moveToManagePage: function(event) {

    wx.request({
      url: 'https://dorm.dormassistant.wang:8080/userInformation/queryUserInformationById',
      data: {
        userId: wx.getStorageSync('openid')
      },
      method: "GET",
      success: function (res) {
        if (res.data.user.isManger != null && res.data.user.isManger === 1){
          wx.navigateTo({
            url: '../managePage/managePage'
          });
        }else{
          wx.showToast({
            title: '抱歉，您不是管理员',
            icon: '',
            duration: 2000
          });
        }
      },
      fail: function (res) {
        wx.showToast({
          title: '网络故障',
          icon: '',
          duration: 2000
        });
      }
    });

    
  },
})

